package logic

import (
	"context"
	"srv/renrenzu"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateGoodsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateGoodsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateGoodsLogic {
	return &UpdateGoodsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateGoodsLogic) UpdateGoods(req *types.UpdateGoodsRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	updategoods, err := l.svcCtx.RenRemZu.UpdateGoods(l.ctx, &renrenzu.UpdateGoodsRequest{
		GoodsId:    req.GoodsId,
		GoodsState: req.GoodsState,
	})

	if err != nil {
		return &types.Response{
			Msg:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Msg:  "商品修改状态成功",
		Code: 200,
		Data: map[string]interface{}{"updategoods": updategoods},
	}, nil

}
